<?php

use think\Facade\Route;
use think\Facade\Env;

$url = Env::get('app.business_url');
$url = explode(',', $url);
Route::domain($url, function () {
    Route::miss('business/main/miss');

    Route::group('base', function () {
        Route::post('upload_img', '/upload_img'); //post 提交数据
        Route::get('getregion', '/getregion'); //post 提交数据
        Route::get('getsons', '/getsons'); //post 提交数据
        Route::get('goodsspec_del', '/goodsspec_del'); //post 提交数据
        Route::rule('getalldata', '/getalldata');
    })->prefix('business/base');

    Route::group('index', function () {
        Route::get('login', '/login');  //登陆页面
        Route::post('login', '/login'); //post 提交数据
        Route::get('logout', '/logout'); //退出登录
    })->prefix('business/index');

    Route::group('main', function () {
        Route::get('index', '/index');  //基础页面,
        Route::get('welcome', '/welcome');  //首页信息页面
        Route::get('404', '/miss');
        Route::rule('admin', '/admin');   //管理员修改个人信息
        Route::rule('jiebang', '/jiebang');   //管理员修改个人信息
    })->prefix('business/main');

    $menu = config('bmenu.menu');

    foreach ($menu as $k => $v) {
        if ($v['show'] == true) {
            Route::group($k, function () use ($v) {
                foreach ($v['sub'] as $x => $y) {
                    Route::rule($x, $y['uri'])->method($y['method']);
                }
            })->prefix('business');
        }
    }
})->bind('business');
